<?php
class rule_greenModel extends RuleModel {
	public function getlist() {
		$zym_13 = $this->select();if (!$zym_13) {
			return array();
		}
		foreach ($zym_13 as &$zym_14) {
			$zym_14['sitename'] = dc::get('novelsearch_site', $zym_14['siteid'], 'name');
			$zym_14['create_username'] = dc::get('user', $zym_14['create_user_id'], 'name');
			$zym_14['update_username'] = dc::get('user', $zym_14['update_user_id'], 'name');
			$zym_14['create_time'] = $zym_14['create_time'] ? date('Y-m-d H:i', $zym_14['create_time']) : '';
			$zym_14['update_time'] = $zym_14['update_time'] ? date('Y-m-d H:i', $zym_14['update_time']) : '';
			$zym_14['url_edit'] = U('rule.green.edit', array('id' => $zym_14['id']));
			$zym_14['url_test'] = U('rule.green.test', array('id' => $zym_14['id']));
			$zym_14['url_run'] = U('rule.green.run', array('id' => $zym_14['id']));}return $zym_13;}public function test($zym_12, $zym_5) {
		$zym_7 = $this->getrule($zym_12);if (!$zym_7) {
			return '没有该站点的阅读规则';
		}

		$zym_15 = $this->getcontent($zym_5, $zym_7);return ($zym_15);}public function collect($zym_12, $zym_5) {
		$zym_7 = $this->getrulebysiteid($zym_12);
		$zym_15 = $zym_7 ? $this->getcontent($zym_5, $zym_7) : '';return $zym_15;}public function getcontent($zym_5, $zym_7) {
		if ($zym_7['url']) {$zym_5 = str_replace('[url]', urlencode($zym_5), $zym_7['url']);}$zym_10 = collect::getcontent($zym_5);
		$zym_6 = collect::getMatch($zym_7['rule'], $zym_10);
		$zym_6 = novel::chapterformat($zym_6);return $zym_6 ? $this->replacecontent($zym_6) : '';}protected function replacecontent($zym_15) {
		$zym_11 = trim($this->config->get('content_replace', null, ''));if ($zym_11) {
			$zym_8 = explode("\n", $zym_11);foreach ($zym_8 as $zym_9) {
				$zym_9 = trim($zym_9);
				$zym_7 = explode('|||', $zym_9);if (!isset($zym_7['1'])) {
					$zym_7['1'] = '';
				}

				$zym_15 = str_replace($zym_7['0'], $zym_7['1'], $zym_15);}}return $zym_15;}}
?>